import { defineStore } from 'pinia'
import type { AdminTable } from '@/api/adminLogin/adminTable'

export const useAdminStore = defineStore('admin', {
  state: (): { admin:  AdminTable| null } => ({
    admin: null
  }),
  actions: {
    // 设置用户信息
    setAdminInfo(info: AdminTable) {
      this.admin = info
    },
    // 清空用户信息
    clearAdminInfo() {
      this.admin = null
    }
  },
  // 持久化配置，将数据存储到 localStorage
  persist: {
    storage: localStorage,
  },
})
